package com.jiangnan.warehouse_management.controller;

import com.jiangnan.warehouse_management.common.Result;
import com.jiangnan.warehouse_management.dto.response.RecordStatsResponse;
import com.jiangnan.warehouse_management.service.RecordStatsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/records")
@RequiredArgsConstructor
public class RecordStatsController {
    private final RecordStatsService recordStatsService;

    @GetMapping("/stats")
    public Result<RecordStatsResponse> getRecordStats(
            @RequestParam(value = "timeRange", required = false) String timeRange,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate
    ) {
        RecordStatsResponse data = recordStatsService.getRecordStats(timeRange, startDate, endDate);
        return Result.success(data);
    }
} 